import com.sun.javafx.scene.control.behavior.TwoLevelFocusBehavior;

import java.util.Arrays;
import java.util.Random;

public class Lottery {

    public static void main(String[] args) {
        int redNum = 6;
        int blueNum = 1;

        int[] redBalls = getTwoColorBall(redNum);
        int[] blueBalls = getTwoColorBall(blueNum);

        System.out.println("红色球:" + Arrays.toString(redBalls));
        System.out.println("蓝色球:" + Arrays.toString(blueBalls));
    }


    /**
     * 双色球生成，中奖号码由6个红色、1个蓝色生成
     * 红色 1~33个不重复
     * 蓝色 1~16个随机
     * @return
     */
    public static int[] getTwoColorBall(int number) {
        Random random = new Random();

        int i = 0;
        int result[] = new int[number];
        while(i < number) {
            int value = random.nextInt(33) + 1;

            if (Arrays.binarySearch(result, value) >= 0) {
                continue;
            }

            result[i] = value;

            i += 1;
        }

        return result;
    }


}
